<template>
  <div class="commands-page">
    <div class="container">
      <h1 class="page-title">服务器指令</h1>
      
      <el-tabs v-model="activeTab" type="border-card">
        <el-tab-pane label="默认权限指令" name="default">
          <el-row :gutter="20">
            <el-col :xs="24" :sm="12" :md="8" v-for="command in defaultCommands" :key="command.id">
              <el-card class="command-card" shadow="hover">
                <template #header>
                  <div class="command-header">
                    <span class="command-name">{{ command.name }}</span>
                    <el-tag type="success" size="small">默认</el-tag>
                  </div>
                </template>
                <div class="command-content">
                  <p class="command-syntax">语法: <code>{{ command.syntax }}</code></p>
                  <p class="command-description">{{ command.description }}</p>
                  <div class="command-examples" v-if="command.examples">
                    <p class="examples-title">示例:</p>
                    <ul>
                      <li v-for="example in command.examples" :key="example">
                        <code>{{ example }}</code>
                      </li>
                    </ul>
                  </div>
                </div>
              </el-card>
            </el-col>
          </el-row>
        </el-tab-pane>
        
        <el-tab-pane label="管理员指令" name="admin">
          <el-row :gutter="20">
            <el-col :xs="24" :sm="12" :md="8" v-for="command in adminCommands" :key="command.id">
              <el-card class="command-card" shadow="hover">
                <template #header>
                  <div class="command-header">
                    <span class="command-name">{{ command.name }}</span>
                    <el-tag type="danger" size="small">管理员</el-tag>
                  </div>
                </template>
                <div class="command-content">
                  <p class="command-syntax">语法: <code>{{ command.syntax }}</code></p>
                  <p class="command-description">{{ command.description }}</p>
                  <div class="command-examples" v-if="command.examples">
                    <p class="examples-title">示例:</p>
                    <ul>
                      <li v-for="example in command.examples" :key="example">
                        <code>{{ example }}</code>
                      </li>
                    </ul>
                  </div>
                </div>
              </el-card>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
      
      <div class="notice-section">
        <el-alert
          title="指令使用说明"
          type="info"
          :closable="false"
          show-icon
        >
          <template #default>
            <ul>
              <li>所有指令都需要在游戏内聊天框中输入</li>
              <li>指令不区分大小写</li>
              <li>方括号 [] 表示可选参数</li>
              <li>尖括号 &lt;&gt; 表示必需参数</li>
              <li>如遇到问题，请联系管理员</li>
            </ul>
          </template>
        </el-alert>
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue'

export default {
  name: 'CommandsPage',
  setup() {
    const activeTab = ref('default')
    
    const defaultCommands = ref([
      {
        id: 1,
        name: '注册',
        syntax: '/register <密码> <确认密码>',
        description: '注册新账户，首次进入服务器需要注册',
        examples: ['/register 123456 123456']
      },
      {
        id: 2,
        name: '登录',
        syntax: '/login <密码>',
        description: '登录已注册的账户',
        examples: ['/login 123456']
      },
      {
        id: 3,
        name: '传送',
        syntax: '/tpa <玩家名>',
        description: '向指定玩家发送传送请求',
        examples: ['/tpa Steve', '/tpahere Steve']
      },
      {
        id: 4,
        name: '回家',
        syntax: '/home [家名]',
        description: '传送到自己的家，可设置多个家',
        examples: ['/home', '/home 主家', '/sethome 主家']
      },
      {
        id: 5,
        name: '皮肤',
        syntax: '/skin <皮肤名>',
        description: '更换玩家皮肤',
        examples: ['/skin steve', '/skin alex']
      },
      {
        id: 6,
        name: '查询',
        syntax: '/whois <玩家名>',
        description: '查询玩家信息',
        examples: ['/whois Steve']
      },
      {
        id: 7,
        name: '恢复',
        syntax: '/heal',
        description: '恢复生命值和饥饿值',
        examples: ['/heal']
      },
      {
        id: 8,
        name: '传送点',
        syntax: '/warp <传送点名>',
        description: '传送到公共传送点',
        examples: ['/warp spawn', '/warp shop']
      }
    ])
    
    const adminCommands = ref([
      {
        id: 1,
        name: '踢出玩家',
        syntax: '/kick <玩家名> [原因]',
        description: '将指定玩家踢出服务器',
        examples: ['/kick Steve', '/kick Steve 违规行为']
      },
      {
        id: 2,
        name: '封禁玩家',
        syntax: '/ban <玩家名> [原因]',
        description: '永久封禁指定玩家',
        examples: ['/ban Steve', '/ban Steve 使用外挂']
      },
      {
        id: 3,
        name: '临时封禁',
        syntax: '/tempban <玩家名> <时间> [原因]',
        description: '临时封禁指定玩家',
        examples: ['/tempban Steve 1d', '/tempban Steve 1h 恶意破坏']
      },
      {
        id: 4,
        name: '解封玩家',
        syntax: '/unban <玩家名>',
        description: '解除玩家的封禁状态',
        examples: ['/unban Steve']
      },
      {
        id: 5,
        name: '游戏模式',
        syntax: '/gamemode <模式> [玩家名]',
        description: '切换游戏模式',
        examples: ['/gamemode creative', '/gamemode survival Steve']
      },
      {
        id: 6,
        name: '传送玩家',
        syntax: '/tp <玩家名> [目标玩家]',
        description: '传送玩家到指定位置',
        examples: ['/tp Steve', '/tp Steve Alex']
      }
    ])

    return {
      activeTab,
      defaultCommands,
      adminCommands
    }
  }
}
</script>

<style scoped>
.commands-page {
  padding: 20px 0;
}

.page-title {
  font-size: 2.5rem;
  font-weight: bold;
  text-align: center;
  margin-bottom: 40px;
  color: #4CAF50;
}

.command-card {
  margin-bottom: 20px;
  height: 100%;
}

.command-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.command-name {
  font-weight: bold;
  color: #4CAF50;
  font-size: 1.1rem;
}

.command-content {
  line-height: 1.6;
}

.command-syntax {
  margin-bottom: 10px;
}

.command-syntax code {
  background: #f5f5f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  color: #e74c3c;
}

.command-description {
  color: #666;
  margin-bottom: 15px;
}

.examples-title {
  font-weight: bold;
  margin-bottom: 8px;
  color: #333;
}

.command-examples ul {
  list-style: none;
  padding: 0;
}

.command-examples li {
  margin-bottom: 5px;
}

.command-examples code {
  background: #f0f8ff;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  color: #2196F3;
}

.notice-section {
  margin-top: 40px;
}

.notice-section ul {
  margin: 10px 0;
  padding-left: 20px;
}

.notice-section li {
  margin-bottom: 5px;
}

@media (max-width: 768px) {
  .page-title {
    font-size: 2rem;
  }
  
  .command-card {
    margin-bottom: 15px;
  }
  
  .command-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
}
</style> 